package com.daidai.testservice

import android.content.Intent
import android.util.Log
import java.lang.reflect.InvocationHandler
import java.lang.reflect.Method


class AMSProxy(
    val iActivityManager: Any
):InvocationHandler {
    override fun invoke(proxy: Any?, method: Method?, args: Array<out Any>?): Any {
        Log.e(
            "MyLog",
            "method name is :" + method!!.name.toString() + " args length is : ${args}   args is :" + args
        )
        if ("startActivity" == method!!.name) {
            // 第三个参数是intent
            val intent = args!![2] as Intent
            Log.e(
                "MyLog",
                "method name is :" + method!!.name.toString() + "   intent is :" + intent.toString() + "   extradata is :" + intent.getStringExtra(
                    "DATA"
                )
            )
        }
        return method!!.invoke(iActivityManager, args)
    }
}